import json
import time
import flask
from concurrent.futures import ThreadPoolExecutor

app = flask.Flask(__name__)
pool = ThreadPoolExecutor()


def read_file():
    time.sleep(0.1)
    return 'file result'


def read_db():
    time.sleep(0.2)
    return 'db result '


def read_api():
    time.sleep(0.3)
    return 'api result'

@app.route('/')
def index():
    return_file = pool.submit(read_file)
    return_db = pool.submit(read_db)
    return_api = pool.submit(read_api)

    return json.dumps({
        'return_file': return_file.result(),
        'return_db': return_db.result(),
        'return_api': return_api.result()
    })


if __name__ == '__main__':
    app.run()
